﻿<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="tabCustomer.ascx.cs"
    Inherits="CustomerService.CustomerTab" %>
<%@ Register TagPrefix="csl" Src="~/ContactPointList.ascx" TagName="ContactPointList" %>

<script type="text/javascript" language="javascript">
    function USCustomerAddress(bUSAddress) {
        if (bUSAddress) {
            document.getElementById("tableUSAddress").style.display = "";
            document.getElementById("tableInternationalAddress").style.display = "none";
        }
        else {
            document.getElementById("tableUSAddress").style.display = "none";
            document.getElementById("tableInternationalAddress").style.display = "";
        }
        if (document.getElementById('<%=RequiredCity.ClientID %>') != null)
            document.getElementById('<%=RequiredCity.ClientID %>').enabled = bUSAddress;
        if (document.getElementById('<%=RequiredZip.ClientID %>') != null)
            document.getElementById('<%=RequiredZip.ClientID %>').enabled = bUSAddress;
        if (document.getElementById('<%=RequiredIntlAddress2.ClientID %>') != null)
            document.getElementById('<%=RequiredIntlAddress2.ClientID %>').enabled = !bUSAddress;
    }

    function InitCustomerTabValidators() {
        tabCustomer_CountryChange();
    }

    function tabCustomer_CountryChange() {
        var ctl = document.getElementById('<%=ddCountry.ClientID %>');
        var id = ctl.options[ctl.selectedIndex].value;
        USCustomerAddress(id == 1 || id == 40);
    }

    function text_onfocus(ctrl, label) {
        if (ctrl.value == label) {
            ctrl.value = '';
            ctrl.className = "normal"
        }
    }

    function text_onblur(ctrl, label) {
        if (ctrl.value == '') {
            ctrl.className = "label"
            ctrl.value = label;
        }
    }
    //Sys.Application.add_load(function () { tabCustomer_CountryChange(); });
    Sys.UI.DomEvent.addHandler(window, "load", tabCustomer_CountryChange);
</script>

<table>
    <tr>
        <td>
            <div class="orderform">
                <table cellspacing="0" cellpadding="0" border="0" class="CustomerEntry" onload="address_onload();">
                    <tr>
                        <td colspan="2">
                            Country<br />
                            <asp:DropDownList ID="ddCountry" TabIndex="0" runat="server" CausesValidation="True" onchange="tabCustomer_CountryChange();">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            Name<br />
                            <asp:TextBox ID="txtName" runat="server" Enabled="false" />
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                            <asp:RequiredFieldValidator ID="Requiredfieldvalidator1" runat="server" Display="None"
                                ControlToValidate="txtFirstName" ErrorMessage="Customer First Name Required" EnableClientScript="true" />
                            <cs:LabeledText ID="txtFirstName" TabIndex="1" runat="server" CausesValidation="True"
                                MaxLength="50" Label="First Name" />
                        </td>
                        <td class="half">
                            <asp:RequiredFieldValidator ID="Requiredfieldvalidator2" ControlToValidate="txtLastName" Display="None"
                                runat="server" ErrorMessage="Customer Last Name Required" EnableClientScript="true" />
                            <cs:LabeledText ID="txtLastName" Label="Last Name" TabIndex="2" runat="server" CausesValidation="True"
                                MaxLength="50" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:RequiredFieldValidator ID="Requiredfieldvalidator3" ControlToValidate="txtAddress1"
                                runat="server" ErrorMessage="Customer Address1 Required" EnableClientScript="true" Display="None" /> 
                            <cs:LabeledText ID="txtAddress1" Label="Address" TabIndex="3" runat="server" CausesValidation="True"
                                MaxLength="100" />
                        </td>
                    </tr>
                </table>
                <table id="tableUSAddress" cellspacing="1" cellpadding="1" border="0" class="CustomerEntry">
                    <tr>
                        <td colspan="2">
                            <cs:LabeledText ID="txtAddress2" Label="Apt. / Unit #" TabIndex="4" runat="server"
                                MaxLength="30" />
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                            <asp:RequiredFieldValidator ID="RequiredCity" ControlToValidate="txtCity"
                                runat="server" ErrorMessage="Customer City Required" EnableClientScript="true" Display="None" />
                            <cs:LabeledText ID="txtCity" Label="City" TabIndex="5" runat="server" CausesValidation="True" />
                        </td>
                        <td class="half">
                            State<br />
                            <asp:DropDownList ID="ddState" TabIndex="6" runat="server" CausesValidation="True">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                            <asp:RequiredFieldValidator ID="RequiredZip" ControlToValidate="txtZip"
                                runat="server" ErrorMessage="Customer Zip Required" EnableClientScript="true" Display="None" />
                            <cs:LabeledText ID="txtZip" Label="Zip" TabIndex="7" runat="server" CausesValidation="True"
                                MaxLength="10" />
                        </td>
                    </tr>
                </table>
                <table id="tableInternationalAddress" cellspacing="1" cellpadding="1" border="0"
                    class="CustomerEntry" style="display: none;">
                    <tr>
                        <td colspan="2">
                            <asp:RequiredFieldValidator ID="RequiredIntlAddress2" ControlToValidate="txtInternationalAddress2"
                                runat="server" ErrorMessage="Customer Address 2 Required" EnableClientScript="true" Display="None" />
                            <cs:LabeledText ID="txtInternationalAddress2" Label="Address Line #2" TabIndex="8"
                                runat="server" MaxLength="30" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <cs:LabeledText ID="txtInternationalAddress3" Label="Address Line #3" TabIndex="9"
                                runat="server" MaxLength="30" />
                        </td>
                    </tr>
                </table>
                <table id="tableEmailPhone" cellspacing="1" cellpadding="1" border="0" class="CustomerEntry">
                    <tr>
                        <td>
                            <csl:ContactPointList ID="ContactPointList" runat="server" />
                        </td>
                    </tr>
                </table>
            </div>
        </td>
        <td valign="top">
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        Customer ID:&nbsp
                        <%=_customer.CustomerID.ToString() %>
                    </td>
                </tr>
                <tr>
                    <td>
                        Preferred Language:<br />
                        <asp:DropDownList ID="ddLanguage" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkAllowRent" runat="server" Text="Allow Rent" ToolTip="Allow selling customer information to third parties" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkAllowPhone" runat="server" Text="Allow Phone" ToolTip="Allow calling customer with offers" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkAllowMail" runat="server" Text="Allow Mail" ToolTip="Allow mailing the customer offers" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkAllowEmail" runat="server" Text="Allow Email" ToolTip="Allow email the customer offers" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkDoNotProcess" runat="server" Text="Disable all processing" ToolTip="Disable any future processing of orders or offers for this customer" />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
